package com.kinghood.productcenter.common.model.enums.product;

import lombok.Getter;

import java.util.Objects;

/**
 * 商品状态（0：未启用；1：待上市；2：在售；3：下架）
 *
 * @author zhangFanJun
 * @date 2023-12-27 14:49
 **/
@Getter
public enum ProductSkuStatusEnums {

    /**
     * 未启用
     * */
    NOT_ENABLE(0,"停用"),
    /**
     * 待上市
     * */
    WAITE_ON(1,"启用");

    private Integer type;
    private String name;

    ProductSkuStatusEnums(Integer type, String name) {
        this.type = type;
        this.name = name;
    }

    public static Integer getTypeByName(String name){
        for (ProductSkuStatusEnums e : values()) {
            if(Objects.equals(name,e.getName())){
                return e.getType();
            }
        }
        return null;
    }

    public static String getNameByType(Integer type){
        for (ProductSkuStatusEnums e : values()) {
            if(Objects.equals(type,e.getType())){
                return e.getName();
            }
        }
        return null;
    }
}
